import {
  GetNotifyListQueryType,
  PublishNotifyType,
} from "../service/systemNotify";

const mockNotifyList: PublishNotifyType[] = [
  {
    id: "1",
    content: "设备1",
  },
  {
    id: "2",
    content: "设备2",
  },
  {
    id: "3",
    content: "设备3",
  },
];

// 生成唯一ID
const generateId = (): string => {
  return Date.now().toString() + Math.random().toString(36).substr(2, 9);
};

// 模拟延迟
const delay = (ms = 300): Promise<void> => {
  return new Promise((resolve) => setTimeout(resolve, ms));
};

// 消息列表
export const mockGetNotifyList = async (
  params: GetNotifyListQueryType
): Promise<{
  status: number;
  data: PublishNotifyType[] | null;
  message: string;
}> => {
  await delay();

  return {
    status: 0,
    data: mockNotifyList,
    message: "获取消息列表成功",
  };
};

// 发布消息的mock
export const mockPublishNotify = async (
  params: PublishNotifyType
): Promise<{
  status: number;
  data: PublishNotifyType | null;
  message: string;
}> => {
  await delay();
  return {
    status: 0,
    data: params,
    message: "发布消息成功",
  };
};
